/// Text Overlay Application: Tools Class
/// This class contains functions that report information contained
/// in Array lists to files. (mainly for Debug propouses)

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.IO;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace TextOverlay
{
    class CTools
    {
        /// <summary>
        /// This function reports the content of an ArrayList as an html file
        /// </summary>
        /// <param name="filename">The name of the output filename</param>
        /// <param name="array">An ArrayList containig the elements to report</param>
        public void ReportAsHTML(string filename, ArrayList array)
        {

            FileStream file = new FileStream(String.Format("C:/{0}.html", filename), FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(file);
            sw.WriteLine("<html><PRE>");
            sw.WriteLine("Report for: " + filename);
            sw.WriteLine(" ");
            for (int i = 0; i < array.Count; i++)
            {
                sw.WriteLine(array[i].ToString());
            }
            sw.WriteLine("</PRE></html>");
            sw.Close();
            file.Close();
        }

        /// <summary>
        /// This function reports the content of an ArrayList as an csv file
        /// </summary>
        /// <param name="filename">The name of the output filename</param>
        /// <param name="array">An ArrayList containig the elements to report</param>
        public void ReportAsCSV(string filename, ArrayList array)
        {
            filename = filename + " " + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
            FileStream file = new FileStream(String.Format("C:/{0}.csv", filename), FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(file, Encoding.Default);
            sw.WriteLine("<html><PRE>");
            sw.WriteLine("Report for: " + filename);
            sw.WriteLine(" ");
            for (int i = 0; i < array.Count; i++)
            {
                sw.WriteLine(array[i].ToString());
            }
            sw.WriteLine("</PRE></html>");
            sw.Close();
            file.Close();

        }

    }
}
